Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐙 octavia-cli: add command to list existing sources, destinations and connections #9642

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Jan 20, 2022

What

  • Add three commands to list existing sources, destinations and connections
  • Improve code architecture to avoid DRY and make heavy use of inheritance

How

  • Refacto existing ConnectorDefinitions class in a BaseListing class hosted in listings.py module.
  • Declare a formatting module that host formatting functions that were declared in ConnectorDefinitions.
  • Make SourcesConnectorsDefinitions, DestinationsConnectorsDefinitions, Sources, Destinations inherit from BaseListing.
  • Declare list sources and list destinations commands.
  • Adapt unit tests to the refacto.

Recommended reading order

  1. octavia-cli/octavia_cli/list/listings.py
  2. octavia-cli/octavia_cli/list/commands.py
  3. octavia-cli/octavia_cli/list/formatting.py
  4. octavia-cli/unit_tests/test_list/test_listings.py
  5. octavia-cli/unit_tests/test_list/test_commands.py
  6. octavia-cli/unit_tests/test_list/test_formatting.py

🚨 User Impact 🚨

Two new commands: octavia list sources and octavia list destinations
Screen Shot 2022-01-20 at 14 17 02

@alafanechere alafanechere changed the title 🐙 octavia-cli: add command to list existing sources and destinations 🐙 octavia-cli: add command to list existing sources, destinations and connections Jan 20, 2022
@alafanechere alafanechere temporarily deployed to more-secrets January 20, 2022 13:37 Inactive
@cgardens cgardens added this to the USE 2022-01-27 milestone Jan 20, 2022
@alafanechere alafanechere temporarily deployed to more-secrets January 20, 2022 22:10 Inactive
Base automatically changed from augustin/octavia-cli/list-connectors to master January 21, 2022 08:14
@alafanechere alafanechere changed the base branch from master to augustin/octavia-cli/list-connectors January 21, 2022 08:18
@alafanechere alafanechere temporarily deployed to more-secrets January 21, 2022 08:24 Inactive
@alafanechere alafanechere marked this pull request as ready for review January 21, 2022 08:26
@alafanechere alafanechere temporarily deployed to more-secrets January 21, 2022 08:28 Inactive
@alafanechere alafanechere temporarily deployed to more-secrets January 21, 2022 08:31 Inactive
@alafanechere
Copy link
Contributor Author

@lmossman I tried to continue to improve inheritances goodies to avoid repeating shared logic between all the listing commands.

@alafanechere alafanechere changed the base branch from augustin/octavia-cli/list-connectors to master January 21, 2022 15:31
@alafanechere alafanechere changed the base branch from master to augustin/octavia-cli/list-connectors January 21, 2022 15:31
@alafanechere alafanechere temporarily deployed to more-secrets January 24, 2022 09:56 Inactive
@alafanechere alafanechere changed the base branch from augustin/octavia-cli/list-connectors to master January 24, 2022 09:56
@alafanechere alafanechere force-pushed the augustin/octavia-cli/list-sources-destinations branch from 453bcaf to 9533e93 Compare January 24, 2022 09:57
@alafanechere alafanechere changed the base branch from master to augustin/octavia-cli/list-connectors January 24, 2022 09:57
@alafanechere alafanechere temporarily deployed to more-secrets January 24, 2022 09:59 Inactive
Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall! Left a few small comments but none of them are blocking, so feel free to merge when you are ready

Comment on lines 9 to 10
"""Compute column width for display purposes:
Find largest column size, add a padding of two characters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method description should be updated to reflect the new implementation

def compute_columns_width(data: List[List[str]], padding: int = 2) -> List[int]:
"""Compute column width for display purposes:
Find largest column size, add a padding of two characters.
Returns:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Returns:
Args:

Comment on lines +93 to +111
class Sources(WorkspaceListing):
api = source_api.SourceApi
fields_to_display = ["name", "sourceName", "sourceId"]
list_field_in_response = "sources"
list_function_name = "list_sources_for_workspace"


class Destinations(WorkspaceListing):
api = destination_api.DestinationApi
fields_to_display = ["name", "destinationName", "destinationId"]
list_field_in_response = "destinations"
list_function_name = "list_destinations_for_workspace"


class Connections(WorkspaceListing):
api = connection_api.ConnectionApi
fields_to_display = ["name", "connectionId", "status", "sourceId", "destinationId"]
list_field_in_response = "connections"
list_function_name = "list_connections_for_workspace"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that these inherit from a WorkspaceListing made me think: would it make sense to group these commands under a workspace keyword? I.e. the commands would look like

octavia list workspace sources
octavia list workspace destinations
octavia list workspace connections
octavia list connectors sources
octavia list connectors destinations

Do you think this would make it more clear what the difference between these commands are to the user? Or would we just end up with a ton of workspace commands, making the commands unnecessarily long?

I'll leave it up to you to make the final decision here; I don't feel super strongly either way, but just thought I would offer this suggestion in case you liked it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, looks tidier and will keep the same command "depth" for list subcommands.

@alafanechere alafanechere temporarily deployed to more-secrets January 25, 2022 08:44 Inactive
@alafanechere alafanechere force-pushed the augustin/octavia-cli/list-sources-destinations branch from 37ae4e3 to 88bfbb2 Compare January 25, 2022 09:01
@alafanechere alafanechere changed the base branch from augustin/octavia-cli/list-connectors to master January 25, 2022 09:02
@alafanechere alafanechere temporarily deployed to more-secrets January 25, 2022 09:03 Inactive
@airbytehq airbytehq deleted a comment from CLAassistant Jan 25, 2022
@alafanechere
Copy link
Contributor Author

Thank you @lmossman for your review and suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants